import { createApp } from 'vue'
import { createPinia } from 'pinia'
import '@/assets/main.scss'
import * as ElementPlusIcons from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css' // 引入暗色主题
import * as socketApi from '@/api/webSocket.js'
import VueVirtualScroller from 'vue3-virtual-scroller'
import 'vue3-virtual-scroller/dist/vue3-virtual-scroller.css'
import ElementPlus from 'element-plus'

import App from './App.vue'
import router from './router'

const app = createApp(App)
// 挂载全局 WebSocket API
app.config.globalProperties.$wsApi = socketApi;

// 把图标引入到全局，这里注意引入的顺序，不然会报错。可以把它写在 createApp(App) 与 app.mount('#app') 之间。

for (const [key, component] of Object.entries(ElementPlusIcons)) {
    app.component(key, component)
}

app.use(createPinia())
app.use(router)
app.use(VueVirtualScroller)
app.use(ElementPlus)

app.mount('#app')